package cn.vehicle.exception;

import cn.vehicle.enums.StatusCode;
import lombok.Data;
import lombok.EqualsAndHashCode;

@EqualsAndHashCode(callSuper = true)
@Data
public class VehicleAccessException extends RuntimeException {

    private String defineCode;

    private String message;

    public static final VehicleAccessException DATE_EXIST = new VehicleAccessException(StatusCode.DATE_EXIST);
    public static final VehicleAccessException SYSTEM_ERROR = new VehicleAccessException(StatusCode.SYSTEM_ERROR);
    public static final VehicleAccessException PARAMS_ERROR = new VehicleAccessException(StatusCode.PARAMS_ERROR);
    public static final VehicleAccessException DATE_NOT_EXIST = new VehicleAccessException(StatusCode.DATE_NOT_EXIST);

    public VehicleAccessException(StatusCode statusCode) {
        this.defineCode = statusCode.getCode();
        this.message = statusCode.getMessage();
    }

    public VehicleAccessException(String defineCode, String message) {
        this.defineCode = defineCode;
        this.message = message;
    }

    public VehicleAccessException newInstance(String message) {
        return new VehicleAccessException(defineCode, message);
    }

}
